#include "camprec.h"
#include "DrawElementsByIndex.h"

//DWORD CDrawElementsByIndex::m_ID = 0;

CDrawElementsByIndex::CDrawElementsByIndex(void)//:IDOGL(0)
{
	//m_ID++;
	//StrID (mystr::format(_T("DrawElementsByIndex%d"),m_ID));
}

CDrawElementsByIndex::~CDrawElementsByIndex(void)
{
	Free ();
}

void CDrawElementsByIndex::Free ()
{
	while (!DrawElementByIndexVector.empty())
	{
		delete DrawElementByIndexVector.back();
		DrawElementByIndexVector.pop_back();
	}
	//FreeChildObj();
}

CDrawElementByIndex* CDrawElementsByIndex::Add (const wstring &Name)
{
	CDrawElementByIndex *pDEBI = new CDrawElementByIndex ();
	DrawElementByIndexVector.push_back (pDEBI);
	pDEBI->Name = Name;

	//RegisterChildObj(pDEBI->StrID(), pDEBI);
	return pDEBI;
}
CDrawElementByIndex* CDrawElementsByIndex::Get (const DWORD &Index)
{
	if (Index < Count ())
		return DrawElementByIndexVector [Index];
	
	return NULL;
}

CDrawElementByIndex* CDrawElementsByIndex::Get (const wstring &Name)
{
	vector<CDrawElementByIndex*>::iterator it;
	for (it = DrawElementByIndexVector.begin(); it < DrawElementByIndexVector.end(); it++)
	{
		if ((*it)->Name == Name)
			return *it;
	}
	return NULL;
}